#import "LayoutManagersViewController.h"
#import "LayoutManagers.h"

@implementation LayoutManagersViewController

- (void)loadView
{
    container = [[UIView alloc] initWithFrame:
                 [[UIScreen mainScreen] applicationFrame]];
    self.view = container;

    vlay = [[VLayoutView alloc] initWithSpacing:5];
    vlay.backgroundColor = [UIColor darkGrayColor];
    [container addSubview:vlay];

    // TOP
    
    topHLay = [[HLayoutView alloc] initWithSpacing:5];
    topHLay.backgroundColor = [UIColor grayColor];
    [vlay addSubview:topHLay];

    topLeftLabel = [[UILabel alloc] init];
    topLeftLabel.text = @"Top Left";
    topLeftLabel.backgroundColor = [UIColor blueColor];
    [topHLay addSubview:topLeftLabel];
    [topLeftLabel sizeToFit];
    
    topRightLabel = [[UILabel alloc] init];
    topRightLabel.text = @"Top Right";
    topRightLabel.backgroundColor = [UIColor redColor];
    [topHLay addSubview:topRightLabel];
    [topRightLabel sizeToFit];
    
    topHLay.autoresizesSubviews = NO;
    [topHLay sizeToFit];
    topHLay.autoresizesSubviews = YES;
    
    // MIDDLE

    middleHLay = [[HLayoutView alloc] initWithSpacing:5];
    middleHLay.backgroundColor = [UIColor grayColor];
    [vlay addSubview:middleHLay];
    
    middleLabel = [[UILabel alloc] init];
    middleLabel.text = @"Middle";
    middleLabel.backgroundColor = [UIColor greenColor];
    [middleHLay addSubview:middleLabel];
    [middleLabel sizeToFit];
        
    middleHLay.autoresizesSubviews = NO;
    [middleHLay sizeToFit];
    middleHLay.autoresizesSubviews = YES;
    
    // BOTTOM
    
    bottomHLay = [[HLayoutView alloc] initWithSpacing:5];
    bottomHLay.backgroundColor = [UIColor grayColor];
    [vlay addSubview:bottomHLay];
    
    bottomLeftLabel = [[UILabel alloc] init];
    bottomLeftLabel.text = @"Bottom Left";
    bottomLeftLabel.backgroundColor = [UIColor blueColor];
    [bottomHLay addSubview:bottomLeftLabel];
    [bottomLeftLabel sizeToFit];
    
    bottomRightLabel = [[UILabel alloc] init];
    bottomRightLabel.text = @"Bottom Right";
    bottomRightLabel.backgroundColor = [UIColor redColor];
    [bottomHLay addSubview:bottomRightLabel];
    [bottomRightLabel sizeToFit];
    
    bottomHLay.autoresizesSubviews = NO;
    [bottomHLay sizeToFit];
    bottomHLay.autoresizesSubviews = YES;
    
    // Set size
    
    vlay.autoresizesSubviews = NO;
    [vlay sizeToFit];
    vlay.autoresizesSubviews = YES;    
}

- (void)dealloc
{
    [bottomRightLabel release];
    [bottomLeftLabel release];
    [bottomHLay release];
    [middleLabel release];
    [middleHLay release];
    [topRightLabel release];
    [topLeftLabel release];
    [topHLay release];
    [vlay release];
    [container release];
    [super dealloc];
}

@end
